﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Data.OleDb;
using System.IO;

namespace KingCat_DataBase
{
    public class DataBaseConnection
    {
        private OleDbConnection conn;
        private static DataBaseConnection dbc;
        private DataBaseConnection()
        {
            string strg = Directory.GetCurrentDirectory();
            strg = strg.Substring(0, strg.LastIndexOf("\\"));
            strg = strg.Substring(0, strg.LastIndexOf("\\"));
            strg += @"\DataBase";
            strg += @"\Server.mdb";
            strg = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + strg;
            conn = new OleDbConnection(strg);
            conn.Open();
        }


        public static DataBaseConnection getInstance()
        {
            if (dbc == null)
            {
                dbc = new DataBaseConnection();
            }
            return dbc;
        }

        public OleDbConnection getConnection()
        {
            return this.conn;
        }

        public void close()
        {
            this.conn.Close();
        }

    }
}
